package com.lingshi.shopping_common.exception;

import cn.dev33.satoken.exception.NotPermissionException;
import com.lingshi.shopping_common.result.BaseResult;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    // 处理业务异常
    @ExceptionHandler(BusException.class)
    public BaseResult busExceptionHandler(BusException e){
        System.out.println("e = " + e);
        return BaseResult.error(e.getCode(),e.getMessage());
    }

    // 处理权限异常
    @ExceptionHandler(NotPermissionException.class)
    public BaseResult busExceptionHandler(NotPermissionException e){
        System.out.println("e = " + e);
        return BaseResult.error(e.getCode(),e.getMessage());
    }
}
